export function formatDateTime(input) {
  if (!input) return '';
  try {
    const d = typeof input === 'string' || typeof input === 'number' ? new Date(input) : input;
    if (Number.isNaN(d.getTime())) return '';
    const Y = d.getFullYear();
    const M = String(d.getMonth() + 1).padStart(2, '0');
    const D = String(d.getDate()).padStart(2, '0');
    const h = String(d.getHours()).padStart(2, '0');
    const m = String(d.getMinutes()).padStart(2, '0');
    const s = String(d.getSeconds()).padStart(2, '0');
    return `${Y}-${M}-${D} ${h}:${m}:${s}`;
  } catch {
    return '';
  }
}
